Fields
Collection Object
The Fields
collection object contains one or more Field objects. Field objects give you
the ability to access properties of the object. These include the predefined
underlying MAPI properties and your own custom user-defined properties.
Quick Info
Specified
in header file: |
MDISP.ODL |
First
available in version: |
OLE
Messaging Library 1.0 |
Parent
objects: |
AddressEntry |
Child
objects: |
Field |
Default
property: |
Item |
A Fields
collection is considered a small collection, which means that it
supports count and index values that let you access an individual Field object
through the Item property. The Fields collection supports the Visual
Basic For Each statement.
Properties
|
Available
in version |
|
|
Application |
1.0 |
String |
Read-only |
Class |
1.0 |
Long |
Read-only |
Count |
1.0 |
Long |
Read-only |
Item |
1.0 |
Field
object |
Read-only |
Parent |
1.0 |
AddressEntry
object, Inbox or Outbox folder object, or Message object |
Read-only |
Session |
1.0 |
Session
object |
Read-only |
Methods
|
Available
in version |
|
Add |
1.0 |
name as
String, |
Delete |
1.0 |
(none) |
SetNamespace |
1.0 |
(optional)
PropsetID as String |
Remarks
MAPI defines
a set of properties with identifiers less than the value 0x8000. These are
known as unnamed properties because they are usually accessed using the
identifier rather than a name. You can access these MAPI-defined properties
using the Fields collection. All MAPI properties are accessible except those of
types PT_OBJECT and PT_CLSID.
You can also
extend the properties available through MAPI by defining your own properties.
These user-defined properties, defined using a name and automatically assigned
an identifier value greater than 0x8000 by the OLE Messaging Library, are known
as named properties. (C++ programmers can access the property name in
the MAPI structure MAPINAMEID and convert it to the property tag value.)
All named
properties are defined as part of a property set, which is also known in
the context of the OLE Messaging Library as a namespace.
A property
set is defined by a GUID, or unique identifier. The OLE Messaging Library
represents this GUID as a string of hexadecimal characters. Such identifiers
are usually referenced using a constant that starts with the characters PS_,
such as PS_PUBLIC_STRINGS, the default property set for all properties created
using the OLE Messaging Library.
You can also
choose to organize your custom properties within their own semantic space by
defining your own property set. The Add and SetNamespace methods
and the Item property let you specify the property set identifier to be
used for property access. When creating your own property set, you should be
aware that MAPI reserves several property set identifiers for specific
purposes. The following table lists reserved property sets:
Reserved
Property Set |
Description |
PS_PUBLIC_STRINGS |
Default
property set for custom properties added using the OLE Messaging Library. |
PS_MAPI |
Allows
providers to supply names for the unnamed properties (properties with
identifiers less than 0x8000). |
PS_ROUTING_DISPLAY_NAME |
Display
name properties that are translated
between messaging domains. |
PS_ROUTING_EMAIL_ADDRESSES |
E-mail
addresses that are translated between messaging domains. |
PS_ROUTING_ADDRTYPE |
E-mail
address types that are translated between messaging domains. |
PS_ROUTING_ENTRYID |
Long-term
entry identifiers that are translated between messaging domains. |
PS_ROUTING_SEARCH_KEY |
Search keys
that are translated between messaging domains. |
To create
your own GUID that identifies your property set, you can either use the Win32
command-line utility UUIDGEN or you can call the OLE function CoCreateGuid
to supply one for you, as demonstrated in the following code:
' declarations required for the call to CoCreateGuid
Type GUID
Guid1 As
Long
Guid2 As
Long
Guid3 As
Long
Guid4 As
Long
End Type
Declare Function CoCreateGuid Lib
"OLE32.DLL" (pGuid As GUID) As Long
Global Const S_OK = 0
Dim strPropID as String
Dim lResult As Long
Dim lGuid As GUID
' call CoCreateGuid, then convert the result to a
hex string
lResult =
CoCreateGuid(lGuid)
If lResult
= S_OK Then
strPropID = Hex$(lGuid.Guid1)
& Hex$(lGuid.Guid2)
strPropID = myHexString & Hex$(lGuid.Guid3)
strPropID = myHexString & Hex$(lGuid.Guid4)
Else
...
handle error...
End If
'
Note that
MAPI stores all custom properties that represent date and time information using
Greenwich Mean Time (GMT). The OLE Messaging Library converts these properties
so that the values appear to the user in local time.
For more
information about properties and property sets, see the topic, About Named
Properties, in the MAPI Programmer s Reference. For more information
about UUIDGEN and CoCreateGuid, see the Win32 SDK documentation.
Example
To uniquely
identify Field objects in the Fields collection, use the Field object s Name
property or an index:
Set objOneField = objFolder.Fields.Item("BalanceDue")
Set objAnotherField =
objMessage.Fields.Item("Keyword")
Set objThirdField = objMessage.Fields.Item(3)
See Also
SetNamespace Method (Fields Collection), Object Collections